function viewProject(pid) {
    winOpen(applicationPath() + "/HMS/Projects/ProjectAdd.aspx?operation=view&type=1&ProjectID=" + pid, 1024, 600)
}
function viewLinkRecord(rid) {
    winOpen(applicationPath() + "/HMS/Projects/ContactList.aspx?from=resumeadd&rid=" + rid);
    return false;
}
function viewProjectList(rid) {
    winOpen(applicationPath() + "/HMS/Resumes/DetailList.aspx?what=inproject&rid=" + rid);
    return false;
}
function viewOperationLog(rid) {
    winOpen(applicationPath() + "/HMS/Resumes/OperationLog.aspx?rid=" + rid);
    return false;
}
function viewResume(rid, pid) {
    var sUrl = applicationPath() + "/HMS/Resumes/ResumeAddUnite.aspx?ProjectID=" + pid + "&id=" + rid;
    winOpen(sUrl);
}
function applicationPath() {
    var sPathName = document.location.pathname;
    var iCount = sPathName.indexOf("/", 1);
    var sPath = sPathName.substring(0, iCount);
    return sPath;
}
function winOpen(SetUrl, SetW, SetH) {
    var windowW = SetW ? SetW : 900;
    var windowH = SetH ? SetH : 600;
    var windowX = Math.ceil((window.screen.width - windowW) / 2);
    var windowY = Math.ceil((window.screen.height - windowH) / 2); //确定网页的坐标 
    window.open(SetUrl, '_blank', 'scrollbars=yes,resizable=yes,top=' + windowY + ',left=' + windowX + ', width=' + windowW + ',height=' + windowH + '');
}
function OpenCustCenterHms(custid) {
    url = applicationPath() + "/Common/Client/ClientCenter.aspx?operation=edit&ID=" + custid + "&BT=Hms&mode=center";
    winOpen(url);
}
function sendMail(sMail, args) {
    winOpen(applicationPath() + '/Common/Email/SendMail.aspx?Address=' + encodeURIComponent(sMail) + args, 850, 560);
}
// 选择客户
function ChooseCust(txtID, txtName, custName) {
    var para = "";
    if (custName != null) para = "&custname=" + custName;
    url = applicationPath() + "/Common/Client/SelectClient.aspx?custidControl=" + txtID + "&custnameControl=" + txtName + para;
    winOpen(url, 900, 600);
}
// 弹出层
function popDiv(title, url, divId, height, clickObj) {
    var divWinHtml = "<table width='100%' border='0' cellspacing='0' cellpadding='0'>"
             + "<tbody><tr class='DGHeaderStyle' height='26' ><td style='text-align:left'>&nbsp;<b>" + title + "</b> </td><td style='text-align: right'>"
                 + "<img onclick='jQuery(\"#" + divId + "\").remove()' src='" + applicationPath() + "/Themes/red/box/open_close.png' title='关闭' style='margin-right: 10px; margin-top: 3px; cursor: pointer;'>"
             + "</td></tr><tr><td colspan='2'>"
                  + "<iframe src='" + url + "' height='" + height + "' width='100%'scrolling='yes' frameborder='0'></iframe>"
             + "</td> </tr></tbody></table>"
    var divWin = jQuery("<div id='" + divId + "'></div>");
    divWin.addClass("DGTableStyle");
    divWin.css({ "position": "absolute", "backgroundColor": "white", "width": "97%", "top": (jQuery(clickObj).position().top + 20) + "px", "left": "15px", "z-index": 10000 })
    divWin.html(divWinHtml);
    divWin.appendTo("body");
}
function highlightBySearch() {
    if (jQuery("#_ctl0_WorkForm_ftSearch_queryTabIndex").val() == "0") {
        // 高级查询
        jQuery("#formblock input[type=text]").each(function () {
            if (this.value == "") return true;
            var idList = new Array()
            var valList = new Array();
            switch (this.id) {
                case "_ctl0_WorkForm_Keyword":
                    var optionVal = jQuery("#_ctl0_WorkForm_KeyWordType").val();
                    if (optionVal != "") {
                        idList.push("_ctl0_WorkForm_" + optionVal);
                        idList.push("_ctl0_WorkForm_R_Resumecn");
                    }
                    else
                        idList = buildClassNameArray();
                    valList = this.value.split(',');
                    break;
                case "_ctl0_WorkForm_R_Resumecn":
                    valList = this.value.split(',');
                    idList.push(this.id);
                    break;
                default:
                    valList = this.value.split(',');
                    if (this.id == "_ctl0_WorkForm_chkListEducation_txtName")
                        idList.push("_ctl0_WorkForm_R_Education");
                    else
                        idList.push(this.id);
                    break;
            }
            for (var j in idList) {
                var eleList = jQuery("." + idList[j].replace("_ctl0_WorkForm_", ""));
                for (var k = 0; k < eleList.length; k++) {
                    var lblEle = jQuery(eleList[k]);
                    var html = lblEle.html();
                    for (var i in valList) {
                        if (!valList[i]) continue;
                        html = html.replace(new RegExp(valList[i], "g"), "<b>" + valList[i] + "</b>");
                    }
                    lblEle.html(html);
                }
            }
        });
    }
    else {
        // 全文搜索
        var keyVal = jQuery("#_ctl0_WorkForm_ftSearch_txtFullText").val();
        if (keyVal == "") return;
        var valList = keyVal.split(" ");
        var idList = buildClassNameArray();
        for (var j in idList) {
            var eleList = jQuery("." + idList[j].replace("_ctl0_WorkForm_", ""));
            for (var k = 0; k < eleList.length; k++) {
                var lblEle = null;
                if (eleList[k].hasChildNodes() && eleList[k].childNodes[0].tagName == "SPAN")
                    lblEle = jQuery(eleList[k].childNodes[0]);
                else
                    lblEle = jQuery(eleList[k]);
                var html = lblEle.html();
                for (var i in valList) {
                    if (!valList[i]) continue;
                    html = html.replace(new RegExp(valList[i], "g"), "<b>" + valList[i] + "</b>");
                }
                lblEle.html(html);
            }
        }
    }
}

function buildClassNameArray() {
    return ["_ctl0_WorkForm_R_NO",
    "_ctl0_WorkForm_R_Name",
    "_ctl0_WorkForm_R_Commend",
    "_ctl0_WorkForm_R_companyNameCN",
    "_ctl0_WorkForm_R_positions",
    "_ctl0_WorkForm_R_Mobile",
    "_ctl0_WorkForm_R_Tel",
    "_ctl0_WorkForm_R_Email",
    "_ctl0_WorkForm_R_WorkExper",
    "_ctl0_WorkForm_R_ProjectExper",
    "_ctl0_WorkForm_R_Edu",
    "_ctl0_WorkForm_R_Tran",
    "_ctl0_WorkForm_R_language",
    "_ctl0_WorkForm_R_Remark",
    "_ctl0_WorkForm_R_Resumecn",
    "_ctl0_WorkForm_R_GraduationColleges",
    "_ctl0_WorkForm_R_Major",
    "_ctl0_WorkForm_R_Education",
    "R_Address",
    "R_WorkYear",
    "R_companyNameCN"];
}